#include "lp_defs.h"
#include "recovery.h"
#include "../core/abstractnode.h"
#include <vector>
#include <string>

bool parse_error=false;

bool m_attached_to_nodes=true;

bool isAttachedToNodes() { return m_attached_to_nodes; }

void deattachFromNodes() {m_attached_to_nodes=false; }

void attachToNodes() { m_attached_to_nodes=true; }

std::vector<std::string *> strings_collector_vector;

std::string * push_string(const char * text)
{
	strings_collector_vector.push_back(new std::string(text));
	return strings_collector_vector[strings_collector_vector.size()-1];
}

void  clear_string_collector()
{
 strings_collector_vector.clear();
}

void          collect_strings()
{
    for (unsigned int i=0;i<strings_collector_vector.size();i++)
		  delete strings_collector_vector[i];
	clear_string_collector();
}

std::vector<AbstractNode *> m_node_collector;

AbstractNode * push_node(AbstractNode * data)
{
	m_node_collector.push_back(data);
	return data;
}

void clear_node_collector()
{
  for (unsigned int i=0;i<m_node_collector.size();i++)
	  m_node_collector[i]->own();
  m_node_collector.clear();
}

void collect_nodes()
{
 for (unsigned int i=0;i<m_node_collector.size();i++)
       delete  m_node_collector[i];
  m_node_collector.clear();
}